<?php

/**
 * @author Dileesh Meladath
 * @copyright 2011
 */

class LanguageManager {

    private $db;
    private $logger;
    
    private static $labels;
    private $lang;
    
    public function __construct() {
		global $db;
		$this->db = $db;
        $this->logger = Logger::getLogger("main");      
	}
    
    public function getLanguageList()
    {
        try {
            $langList = array();
            
            $sql  = "SELECT Id, Name FROM language";
            if($this->logger->isDebugEnabled()) {
		      $this->logger->debug("Load Language list sql: ".$sql);
            }
            
            $recordSet = $this->db->CacheExecute($sql); 
            
            if (!$recordSet) {
               $this->logger->Error("Load Language list: ".$sql);
            } else {                
                while (!$recordSet->EOF) {                    
                    $langs = array("id" => $recordSet->fields["Id"], "value" => $recordSet->fields["Name"]);                    
                    array_push($langList,$langs);
                    $recordSet->MoveNext(); 
                }
                $recordSet->Close(); # optional    
            }    
        } catch(Exception $e) {
            $this->logger->Error("Exception in getLanguageList: ".$e); 
        }  
        
        return $langList;  
    }    
}

?>